package com.android.systemui.ios.wall;

import com.android.systemui.ios.R;

import org.json.JSONObject;

public class ItemSetting {
    private int mId;
    private int mType;
    private int mTitle;
    private String mLockBmpPath;
    private String mLockThumbPath;
    private int mIconOverlayResId;
    private boolean mIsIcon;
    private int mIconRes;

    public JSONObject toJson() {
        try {
            JSONObject object = new JSONObject();
            object.put("mId", mId);
            object.put("mType", mType);
            object.put("mTitle", mTitle);
            object.put("mLockBmpPath", mLockBmpPath);
            object.put("mLockThumbPath", mLockThumbPath);
            object.put("mIconOverlayResId", mIconOverlayResId);
            object.put("mIsIcon", mIsIcon);
            object.put("mIconRes", mIconRes);
            return object;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public ItemSetting(JSONObject object) {
        try {
            mId = object.optInt("mId");
            mType = object.optInt("mType");
            mTitle = object.optInt("mTitle");
            mLockBmpPath = object.optString("mLockBmpPath");
            mLockThumbPath = object.optString("mLockThumbPath");
            mIconOverlayResId = object.optInt("mIconOverlayResId");
            mIsIcon = object.optBoolean("mIsIcon");
            mIconRes = object.optInt("mIconRes");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static final int TYPE_SPACE = 0;
    public static final int TYPE_DEFAULT = 1;
    public static final int TYPE_WEATHER = 2;
    public static final int TYPE_EMOJI = 3;
    public static final int TYPE_COLLECTIONS = 4;
    public static final int TYPE_COLOR = 5;
    public static final int TYPE_FEATURED = 6;
    public static final int TYPE_ADD = 7;
    public static final int TYPE_ICON = 8;
    public static final int TYPE_ICON_PHOTO = 9;
    public static final int TYPE_ICON_SHUFFLE = 10;
    public static final int TYPE_ICON_EMOJI = 11;
    public static final int TYPE_ICON_WEATHER = 12;
    public static final int TYPE_ICON_ASTRONOMY = 13;
    public static final int TYPE_ICON_COLOR = 14;

    public ItemSetting(int id, int type, String path) {
        //mLiveWallpaperType = 0;
        mId = id;
        //color = -1;
        mType = type;
        mTitle = getTitleByType();
        mLockBmpPath = path;

        mIsIcon = false;
    }

    //for add
    public ItemSetting(int type, String thumbpath, String path, int overlayResId, boolean icon) {
        //mLiveWallpaperType = 0;
        mId = -1;
        //color = -1;
        mType = type;
        mLockThumbPath = thumbpath;
        mLockBmpPath = path;
        mTitle = -1;
        mIconOverlayResId = overlayResId;
        mIsIcon = icon;
    }

    //for add title
    public ItemSetting(int type, boolean icon) {
        //mLiveWallpaperType = 0;
        mId = -1;
        //color = -1;
        mType = type;
        //mLockBmp = null;
        mTitle = getTitleByType();
        mIconRes = getIconByType();
        mIconOverlayResId = -1;
        mIsIcon = icon;
    }

	/*
	private Bitmap getBitmapByType(){
		switch(mType) {
			case TYPE_DEFAULT:
			case TYPE_ADD:
				if(mLockBmpPath != null)
					mLockBmp = BitmapFactory.decodeFile(mLockBmpPath);
				break;
			default :
				break;
		}
		return mLockBmp;
	}*/

    private int getTitleByType() {
        switch (mType) {
            case TYPE_DEFAULT:
                return R.string.ip_lock_title_favorites;
            case TYPE_ADD:
                return R.string.ip_lock_title_create;
            case TYPE_WEATHER:
            case TYPE_ICON_WEATHER:
                return R.string.ip_icon_new_wallpaper_weather;
            case TYPE_EMOJI:
            case TYPE_ICON_EMOJI:
                return R.string.ip_icon_new_wallpaper_emoji;
            case TYPE_COLLECTIONS:
                return R.string.ip_lock_collections_title;
            case TYPE_COLOR:
            case TYPE_ICON_COLOR:
                return R.string.ip_icon_new_wallpaper_color;
            //just for icon
            case TYPE_ICON_PHOTO:
                return R.string.ip_icon_new_wallpaper_photo;
            case TYPE_ICON_SHUFFLE:
                return R.string.ip_icon_new_wallpaper_shuffle;
            case TYPE_ICON_ASTRONOMY:
                return R.string.ip_icon_new_wallpaper_astronomy;
            //no featured type finally!
            case TYPE_FEATURED:
                return R.string.ip_lock_featured_title;
            default:
                return -1;
        }
    }

    //just for icon
    private int getIconByType() {
        switch (mType) {
            case TYPE_ICON_WEATHER:
                return R.drawable.ip_icon_new_wallpaper_weather;
            case TYPE_ICON_EMOJI:
                return R.drawable.ip_icon_new_wallpaper_emoji;
            case TYPE_ICON_COLOR:
                return R.drawable.ip_icon_new_wallpaper_color;
            case TYPE_ICON_PHOTO:
                return R.drawable.ip_icon_new_wallpaper_photo;
            case TYPE_ICON_SHUFFLE:
                return R.drawable.ip_icon_new_wallpaper_shuffle;
            case TYPE_ICON_ASTRONOMY:
                return R.drawable.ip_icon_new_wallpaper_astronomy;
            default:
                return -1;
        }
    }

    public ItemSetting(int type) {
        //mLiveWallpaperType = 0;
        mId = -1;
        //color = -1;
        mType = type;
        //font = getRandomFonts();
    }

    public int getId() {
        return mId;
    }

    public void setId(int i) {
        mId = i;
    }

    public int getType() {
        return mType;
    }

    public int getTitle() {
        return mTitle;
    }

    //public Bitmap getBitmap() {
    //    return mLockBmp;
    //}

    public String getBitmapPath() {
        return mLockBmpPath;
    }

    //public void setBitmap(Bitmap bmp){
    //	mLockBmp = bmp;
    //}

    public String getThumPath() {
        return mLockThumbPath;
    }

    //just for add new
    public int getIconOverlayResId() {
        return mIconOverlayResId;
    }

    public int getIconResId() {
        return mIconRes;
    }

    public boolean getIsIcon() {
        return mIsIcon;
    }
}
